/**
 * Created by Administrator on 2016/7/15 0015.
 */
$(document).ready(function () {
    tab_start();
    tab_click();
});
function tab_start() {
    $(".tab-bottom-left").find("div").each(function (index) {
        if (index == 0) {
            $(this).css({"background-color": "#e1515b", "color": "#fff"})
        }
    });
    $(".tab-content").each(function (index) {
        if (index == 0) {
            $(this).css({"display": "block"});
        }
    });
}

function tab_click() {
    var tab_btn = $(".tab-bottom-left").find("div");
    tab_btn.each(function (index) {
        $(this).click(function () {
            tab_btn.unbind();
            var tab_this = $(this);
            var obj = "";
            var obj_next = "";
            if ($(this).css("color") == "rgb(255, 255, 255)") {
                tab_click();
            } else {
                $(".tab-content").each(function (i) {
                    if ($(this).css("display") == "block") {
                        obj = $(this);
                    }else  if (i == index) {
                        obj_next = $(this);
                    }
                });
            }
            if (obj != "" && obj_next != "") {
                tab_animate(obj, obj_next,tab_this);
            } else {
                tab_click();
            }
        });
    });
}

function tab_animate(obj, obj_next,tab_this) {
    $(".tab-bottom-left").find("div").css({"background-color":"transparent","color":"#a4a4a4"});
    tab_this.css({"background-color": "#e1515b", "color": "#fff"});
    obj_next.css({"left": "724px", "display": "block"}).animate({
        "left": "0"
    }, 400);
    obj.animate({
        "left": "-724px"
    }, 400, function () {
        obj.css("display","none");
        tab_click();
    });
}